package com.ztt.mapper;

import com.ztt.pojo.entity.zttPurchase;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface PurchaseMapper {

    @Select("select * from purchases ")
    public List<zttPurchase> selectAllPurchase();

    @Insert("insert into purchases (Purchase_id, Employee_id, Purchase_quantity, Purchase_total_price, Purchase_time, Notes)"
            +"values (#{purchaseID}, #{employeeID}, #{purchaseQuantity}, #{purchaseTotalPrice}, #{purchaseTime}, #{notes})")
    public void insertPurchase(zttPurchase purchase);

    @Select("select * from purchases where Purchase_id = #{purchaseID}")
    public zttPurchase getPurchaseById(zttPurchase purchase);

    @Select("select * from purchases where Employee_id = #{employeeID}")
    public List<zttPurchase> getPurchaseByEmployeeId(zttPurchase purchase);

    @Update("update purchases "+
            "set Purchase_id = #{purchaseID} , Employee_id = #{employeeID} , Purchase_quantity = #{purchaseQuantity} ,"+
            " Purchase_total_price = #{purchaseTotalPrice} , Purchase_time = #{purchaseTime} , Notes = #{notes}"+
            " where Purchase_id = #{purchaseID}")
    public void updatePurchase(zttPurchase purchase);


    @Delete("delete from purchases where Purchase_id = #{purchaseID}")
    public void deletePurchase(zttPurchase purchase);

}
